
#include<cstdio>
#include<cstring>
char p[1000010];
int next[1000010];
int len;
void make_next()
{
	len=strlen(p+1);
	next[1]=0;
	int k=0;
	for(int i=2;i<=len;i++)
	{
		while(k>0&&p[k+1]!=p[i])
			k=next[k];
		if(p[k+1]==p[i])k++;
		next[i]=k;
	}
}
int main()
{
	freopen("test.in","r",stdin);
	int n,count=0;
	while(scanf("%d",&n),n!=0)
	{
		memset(next,0,sizeof(next));
		scanf("%s",p+1);
		make_next();
		count++;
		printf("Test case #%d\n",count);
		for(int i=2;i<=len;i++)
		{

			int t=i-next[i];
			if(next[i]!=0&&i%t==0)printf("%d %d\n",i,i/t);
		}
		printf("\n");
	}
	return 0;
}

	
